import time
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Edge()
driver.get("http://121.43.169.97:8848/pageA.html")
driver.maximize_window()
time.sleep(1)
# 定位alerta按钮并点击
driver.find_element(By.XPATH,"/html/body/div/fieldset/form/p[7]/input[1]").click()
# 获取警告框
alert = driver.switch_to.alert
time.sleep(2)
# 关闭警告框
alert.dismiss()
time.sleep(2)
driver.find_element(By.XPATH,"/html/body/div/fieldset/form/p[1]/input").send_keys("admin")
time.sleep(2)
driver.quit()

#   alert.text --> 返回alert/confirm/prompt中的文字信息
#   alert.accept() --> 接受对话框选项
#   alert.dismiss() --> 取消对话框选项